package common;

import dao.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘柄华
 * Date: 2022-06-19
 * Time: 19:45
 */
public class Util {
    public static User checkLoginStatus(HttpServletRequest req){
        // 判断 是否 处于登录状态
        // 如果可以获取到session 里的 User 对象 就认为是登录状态
        HttpSession session = req.getSession(false);
        if (session == null){
            return null;
        }
        User user = (User) session.getAttribute("user");

        if (user == null){
            return null;
        }
        return user;
    }
}
